{include file="public/header" /}




<div class="page">
    <form method="get" name="formSearch" id="formSearch">
        <div class="ds-search-form">
            <dl>
                <dt>{$Think.lang.member__index_name_search}</dt>
                <dd><input class="txt" name="search_name" id="search_name" value="{$search_name}" type="text"></dd>
            </dl>
            <dl>
                <dt>{$Think.lang.member__index_mobile_search}</dt>
                <dd><input class="txt" name="search_phone" id="search_phone" value="{$search_phone}" type="text"></dd>
            </dl>
            <dl>
                <dt>{$Think.lang.member_index_sreaid_search}</dt>
                <dd>
                    <input type="hidden" value="{$ziworkDetail.id}" name="workid">
                    <input type="hidden" value="{$ziworkDetail.typeid}" name="typeid">
                    <input type="hidden" value="{$province_id}" name="province_id" id="_area_1">
                    <input type="hidden" value="{$city_id}" name="city_id" id="_area_2">
                    <input type="hidden" value="{$area_id}" name="area_id" id="_area_3">
                    <input type="hidden" name="areainfo" id="areainfo" value="{$areainfo}"/>
                </dd>
            </dl>
            <dl>
                <dt>{$Think.lang.member_status_search}</dt>
                <dd>
                    <select name="status_search" id="typeid">
                        <option value="">--请选择</option>
                        <option value="1" {if $status_search == 1} selected{/if}>{$Think.lang.member_status_1}</option>
                        <option value="2" {if $status_search == 2} selected{/if}>{$Think.lang.member_status_2}</option>
                        <option value="3" {if $status_search == 3} selected{/if}>{$Think.lang.member_status_3}</option>
                    </select>
                </dd>
            </dl>
            <div class="btn_group">
                <a href="javascript:document.formSearch.submit();" class="btn " title="{$Think.lang.ds_query}">{$Think.lang.ds_query}</a>
                {if $search_name != '' || $search_phone !=''  || $status_search !='' || $province_id!=''}
                <a class="btn" id ='qu_btn' href="/admin/Ziwork/fenpei?workid={$workid}&typeid={$typeid}" title="{$Think.lang.ds_cancel_search}"><span>{$Think.lang.ds_cancel_search}</span></a>
                {/if}
                <!--href=""  -->
                <!--<a class="btn btn-default" href="javascript:export_xls('{:url('Brand/export_step1')}')"><span>{$Think.lang.ds_export}Excel</span></a>-->
            </div>
        </div>
        <input type="hidden" value="" name="export">
    </form>
    <table class="ds-default-table">
        <thead>
        <tr class="thead">
            <th class="w24"></th>
            <th class="w150">{$Think.lang.member_index_name}</th>
            <th class="w48 align-center">{$Think.lang.member_index_mobile}</th>
            <th class="w48 align-center">{$Think.lang.member_index_true_name}</th>
            <th class="w48 align-center">{$Think.lang.member_areainfo}</th>
            <th class="w48 align-center">{$Think.lang.member_status}</th>
        </tr>
        </thead>
        <tbody>
        {notempty name="list"}
        {foreach name="list" item="v"}
        <tr class="hover edit" id="ds_row_{$v.member_id}">
            <td>
                {if strpos($ziworkDetail.userids,','.$v.member_id.',') !== false}
                    <input  checked value="{$v.member_id}" class="checkitem" type="checkbox" name="del_brand_id[]"  id="{$v.member_id}">
                {elseif strpos($useridStr,','.$v.member_id.',') !== false}
                {$Think.lang.member_status_2}
                {else}
                   <input value="{$v.member_id}" class="checkitem" type="checkbox" name="del_brand_id[]"  id="{$v.member_id}">
                {/if}
            </td>
            <td class="name">{$v.member_name}</td>
            <td class="account">{$v.member_name}</td>
            <td class="account">{$v.member_truename}</td>
            <td class="account">{$v.member_areainfo}</td>
            <td class="account">
                {if strpos($ziworkDetail.userids,','.$v.member_id.',') !== false}{$Think.lang.member_status_1}
                {elseif strpos($useridStr,','.$v.member_id.',') !== false}{$Think.lang.member_status_2}
                {else}{$Think.lang.member_status_3}
                {/if}
            </td>

        </tr>
        {/foreach}
        {else /}
        <tr class="no_data">
            <td colspan="10">{$Think.lang.ds_no_record}</td>
        </tr>
        {/notempty}
        </tbody>
        <tfoot>
        {notempty name="list"}
        <tr colspan="15" class="tfoot">
            <td><input type="checkbox" class="checkall" id="checkallBottom"></td>
            <td colspan="16">
                <label for="checkallBottom">{$Think.lang.ds_select_all}</label>
                <!--&nbsp;&nbsp;<a href="JavaScript:void(0);" class="btn btn-small"><span>设置</span></a>-->
            </td>
        </tr>
        {/notempty}
        </tfoot>
    </table>
    {$showpage}
    <div class="clear"></div>
    <div class="bottom tc hr32">
        <input type="button" class="submit" value="设置" id='button_submit'  onclick="submit_up()"/>
    </div>
</div>
<script type="text/javascript" src="{$Think.ADMIN_SITE_ROOT}/js/jquery.edit.js" charset="utf-8"></script>
<script type="text/javascript">
    $(function() {
        $("#areainfo").ds_region();
        var cookiename = "checkStr{:$ziworkDetail.id}";
        var url =document.referrer;
        if (url.indexOf('index') !=-1)
        {
            document.cookie=cookiename+"="+'{:$ziworkDetail.userids}'
        }
        var checkStr1 = getCookie(cookiename);
        var checkArr = checkStr1.split(',');
        checkArr.forEach(function(element) {
            if (element)
            {
                var id = '#'+element;
                $(id).attr('checked', 'checked');
            }
        });
        window.onbeforeunload=function(e) {
            obj = document.getElementsByName("del_brand_id[]");
            if (!checkStr1) {
                check_val = ',';
            }else {
                check_val = '';
            }
            for (k in obj) {
                if (obj[k].checked) {
                    var check = ','+obj[k].value + ','; //查看当前id是否存在cookie
                    if (checkStr1.indexOf(check) == -1)
                    {
                        check_val =check_val+obj[k].value + ',';
                    }
                }else if (obj[k].value != undefined){
                    var check = ','+obj[k].value + ',';
                    if (checkStr1.indexOf(check) != -1)
                    {
                        checkStr1 = checkStr1.replace(new RegExp(check,'g'),',')
                    }
                }else{
                }
            }
            if (checkStr1) {
                check_val = checkStr1 + check_val;
            }
            document.cookie=cookiename+"="+check_val;
        }
    });
    function submit_up(ids_str){
        var cookiename = "checkStr{:$ziworkDetail.id}";
        var checkStr2 = getCookie(cookiename);
        obj = document.getElementsByName("del_brand_id[]");
        if (!checkStr2) {
            check_val = ',';
        }else {
            check_val = '';
        }
        // console.log(checkStr2);
        for (k in obj) {
            console.log(check_val)
            if (obj[k].checked) {
                var check = ','+obj[k].value + ','; //查看当前id是否存在cookie
                // console.log(check);
                if (checkStr2.indexOf(check) == -1)
                {
                    // if (!checkStr2){
                    //     check_val =','+obj[k].value + ',';
                    // }else {
                        check_val =check_val+obj[k].value + ',';
                    // }
                }
            }else if (obj[k].value != undefined){
                var check = ','+obj[k].value + ',';
                if (checkStr2.indexOf(check) != -1)
                {
                    checkStr2 = checkStr2.replace(new RegExp(check,'g'),',')
                }
            }else{
            }
        }
        if (checkStr2) {
            check_val = checkStr2 + check_val;
        }
        document.cookie=cookiename+"="+check_val;
        // alert(check_val)
        _uri = ADMINSITEURL+"/Ziwork/savefenpei.html?memberid=" + check_val+'&workid='+{:$ziworkDetail.id};
        dsLayerConfirm(_uri,'您确定要这样设置吗?');
    }

    function getCookie(c_name) {
        if (document.cookie.length > 0)     {
            c_start = document.cookie.indexOf(c_name + "=")
            if (c_start != -1){
                c_start = c_start + c_name.length + 1
                c_end = document.cookie.indexOf(";", c_start)
                if (c_end == -1)
                    c_end = document.cookie.length
                return unescape(document.cookie.substring(c_start, c_end))
            }
        }
        return ""
    }

</script>
